<html>
<head><meta charset="utf-8"><title>Limits of software implementations · project-portable-simd · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/index.html">project-portable-simd</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Limits.20of.20software.20implementations.html">Limits of software implementations</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="232916957"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Limits%20of%20software%20implementations/near/232916957" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Limits.20of.20software.20implementations.html#232916957">(Apr 02 2021 at 16:08)</a>:</h4>
<p>LLVM doesn't offer saturating ops that aren't add/sub and left shift for integers, and that last one was added only very recently so it's not available for most. So I opened <a href="https://github.com/rust-lang/stdsimd/pull/87">https://github.com/rust-lang/stdsimd/pull/87</a> because the behavior of abs/neg with MIN are a huge gotcha, and getting working saturating versions seems desirable.</p>
<p>That leaves out saturating mul. That's only offered in fixed point arithmetic, which seemed like it might do weird things if we turned integers into fixed-point and then multiplied them, so I also jiggered a software unsigned integer saturating multiply into existence, but I didn't PR that yet because I wanted to ask if that is even a good idea.</p>



<a name="232917552"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Limits%20of%20software%20implementations/near/232917552" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Limits.20of.20software.20implementations.html#232917552">(Apr 02 2021 at 16:13)</a>:</h4>
<p>LLVM supports fixed-point fractional arithmetic?</p>



<a name="232918440"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Limits%20of%20software%20implementations/near/232918440" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Limits.20of.20software.20implementations.html#232918440">(Apr 02 2021 at 16:20)</a>:</h4>
<p>apparently.</p>



<a name="232928679"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Limits%20of%20software%20implementations/near/232928679" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Limits.20of.20software.20implementations.html#232928679">(Apr 02 2021 at 17:36)</a>:</h4>
<p>where the hell is my core::fixed_point rfc</p>



<a name="232959146"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Limits%20of%20software%20implementations/near/232959146" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Limits.20of.20software.20implementations.html#232959146">(Apr 02 2021 at 22:27)</a>:</h4>
<p>afaict using the saturating fixed-point ops with scale=0 gives the corresponding integer ops, so you can express saturating <code>u16</code> multiplication using <code>@llvm.umul.fix.sat.i16(i16 %a, i16 %b, i32 0)</code></p>



<a name="233240033"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Limits%20of%20software%20implementations/near/233240033" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Limits.20of.20software.20implementations.html#233240033">(Apr 05 2021 at 22:27)</a>:</h4>
<p><span class="user-mention silent" data-user-id="229517">Jacob Lifshay</span> <a href="#narrow/stream/257879-project-portable-simd/topic/Limits.20of.20software.20implementations/near/232959146">said</a>:</p>
<blockquote>
<p>afaict using the saturating fixed-point ops with scale=0 gives the corresponding integer ops, so you can express saturating <code>u16</code> multiplication using <code>@llvm.umul.fix.sat.i16(i16 %a, i16 %b, i32 0)</code></p>
</blockquote>
<p>wrt this I'm mostly concerned about some rounding rule kicking in somewhere.</p>



<a name="233240165"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Limits%20of%20software%20implementations/near/233240165" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Limits.20of.20software.20implementations.html#233240165">(Apr 05 2021 at 22:29)</a>:</h4>
<p>I think it should be the same but I think this is where the proptests help</p>



<a name="233254664"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Limits%20of%20software%20implementations/near/233254664" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Limits.20of.20software.20implementations.html#233254664">(Apr 06 2021 at 01:41)</a>:</h4>
<p>truuu</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>